package wangjg.coco.actions;


import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;

import wangjg.coco.views.CharsetDialog;
/**
 * 通过os打开对应的资源
 * @author wangjigang1
 *
 */
public class CharsetPopupMenuAction implements IObjectActionDelegate {
 
	private Shell shell;
	
	/**
	 * Constructor for Action1.
	 */
	public CharsetPopupMenuAction() {
		super();
	}
 
	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
		this.shell = targetPart.getSite().getShell();
	}
 
	public void run(IAction action) {
		CharsetDialog dialog = new CharsetDialog(new Shell());
		dialog.setSelection(selection);
		dialog.open();
	}

	private IStructuredSelection selection;
	 
	public void selectionChanged(IAction action, ISelection selection) {
		if(selection instanceof  IStructuredSelection){
			this.selection = (IStructuredSelection) selection;
		}
	} 
 
}